﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace TeF.Runner.UI
{
    [ValueConversion(typeof (TestState), typeof (Color))]
    public class TextStateToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof (Color))
                throw new ArgumentException("targetType");

            if (value is TestState)
                switch ((TestState) value)
                {
                    case TestState.Loaded:
                    case TestState.Passed:
                    case TestState.Failed:
                        return Colors.Black;
                    case TestState.Skipped:
                        return Colors.DarkGray;
                }

            throw new NotSupportedException(value.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
